package com.whosly.demo.benchmark.sort;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.IntStream;

/**
 * @author fengyang
 * @date 2023/6/15 上午7:27
 * @see <a href="fengyang@stoneatom.com">mailTo: fengyang@stoneatom.com</a>
 */
public class AbstractMockData
{

    public static final Map<String, int[]> ARR_MAP = new HashMap<>();

    static {
//        long startTime = System.currentTimeMillis();

        ARR_MAP.put("300", IntStream.range(0, 300).toArray());
        ARR_MAP.put("1000", IntStream.range(0, 1000).toArray());
        ARR_MAP.put("3000", IntStream.range(0, 3000).toArray());
        ARR_MAP.put("5000", IntStream.range(0, 5000).toArray());
        ARR_MAP.put("10000", IntStream.range(0, 10000).toArray());
        ARR_MAP.put("20000", IntStream.range(0, 20000).toArray());
        ARR_MAP.put("50000", IntStream.range(0, 50000).toArray());
        ARR_MAP.put("100000", IntStream.range(0, 100000).toArray());
        ARR_MAP.put("200000", IntStream.range(0, 200000).toArray());
        ARR_MAP.put("300000", IntStream.range(0, 300000).toArray());
        ARR_MAP.put("500000", IntStream.range(0, 500000).toArray());
        ARR_MAP.put("1000000", IntStream.range(0, 1000000).toArray());
        ARR_MAP.put("5000000", IntStream.range(0, 5000000).toArray());
        ARR_MAP.put("10000000", IntStream.range(0, 10000000).toArray());

//        System.out.println("数据准备时间:" + (System.currentTimeMillis() - startTime) + " ms");
    }

    protected final int[] getData(String key) {
        if(ARR_MAP.containsKey(key)) {
            return ARR_MAP.get(key);
        }

        ARR_MAP.put(key, IntStream.range(0, Integer.parseInt(key)).toArray());
        return ARR_MAP.get(key);
    }
}
